# Predefine names for table data
from enum import Enum, unique


class Units(str, Enum):
    """Predefined unit names for table data"""

    def __new__(cls, value, title):
        obj = str.__new__(cls, value)
        obj._value_ = value
        obj._title = title  # type: ignore
        return obj

    @property
    def title(self):
        return self._title  # type: ignore

    ####################
    # Basic units
    ####################
    # Length units
    km = "km", "千米"
    m = "m", "米"
    cm = "cm", "厘米"
    mm = "mm", "毫米"

    # Area units
    km2 = "km^2", "平方千米"
    hm2 = "hm^2", "公顷"
    m2 = "m^2", "平方米"
    dm2 = "dm^2", "平方分米"
    cm2 = "cm^2", "平方厘米"
    mm2 = "mm^2", "平方毫米"

    # Volume units
    m3 = "m^3", "立方米"
    dm3 = "dm^3", "立方分米"
    cm3 = "cm^3", "立方厘米"
    mm3 = "mm^3", "立方毫米"

    # Mass units
    mg = "mg", "毫克"
    g = "g", "克"
    kg = "kg", "千克"

    # Force units
    N = "N", "牛顿"
    kN = "kN", "千牛"

    # Pressure units
    Pa = "Pa", "帕"
    kPa = "kPa", "千帕"
    MPa = "MPa", "兆帕"
    GPa = "GPa", "吉帕"

    # Angle units
    DEGREE = "^o", "度"
    rad = "rad", "弧度"

    # Temperature units
    CELSIUS = "C^o", "摄氏度"
    FAHRENHEIT = "F^o", "华氏度"

    # Time units
    s = "second", "秒"
    minunte = "minute", "分钟"
    h = "hour", "小时"
    d = "day", "天"
    month = "month", "月"
    year = "year", "年"

    # Currency units
    yuan = "元", "元"
    wan_yuan = "万元", "万元"

    # Density units
    g_cm3 = "g/cm^3", "克每立方厘米"
    kg_m3 = "kg/m^3", "千克每立方米"
    t_m3 = "t/m^3", "吨每立方米"
    kN_m3 = "kN/m^3", "千牛每立方米"
    mg_L = "mg/L", "毫克每升"
    mg_kg = "mg/kg", "毫克每千克"

    # Velocity units
    m_s = "m/s", "米每秒"
    L_s = "L/s", "升每秒"
    m3_s = "m^3/s", "立方米每秒"
    cm_s = "cm/s", "厘米每秒"
    m_d = "m/d", "米每天"

    # Electrical units
    ohm_m = "\Omega·m", "欧姆米"

    ###########
    # Derived units
    ###########
    MPa_i1 = "MPa^{-1}", "兆帕的倒数"
    m2_Mpa_d = "m^2/MPa/d", "平方米每兆帕每天"
    m3_t = "m^3/t", "立方米每吨"
    mmol_L = "mmol/L", "毫摩尔每升"

    #################
    # Dimensionless
    #################
    PERCENT = "\\%", "百分比"
    PERMILLE = "‰", "千分比"
    UNITLESS = "-", "无量纲"

    def __str__(self):
        return self.value


@unique
class GeoMaterialProps(str, Enum):
    """Predefined material property names for geological materials"""

    def __new__(cls, value, title):
        obj = str.__new__(cls, value)
        obj._value_ = value
        obj._title = title  # type: ignore
        return obj

    @property
    def title(self):
        return self._title  # type: ignore

    MaterialID = "material_id", "材料ID"
    Texture = "texture", "纹理"
    MaterialName = "material_name", "岩土名称"
    LayerNumber = "layer_number", "地层编号"
    LayerName = "layer_name", "地层名称"
    WeatheringDegree = "weathering_degree", "风化程度"
    NaturalDensity = "natural_density", "天然密度"
    UnitWeight = "unit_weight", "重度"
    SaturateUnitWeight = "saturate_unit_weight", "饱和重度"
    Cohesion = "cohesion", "黏聚力"
    InternalFrictionAngle = "internal_friction_angle", "内摩擦角"
    CompressionFactor = "compression_factor", "压缩系数"
    CompressionFactor_50to150 = "compression_factor_50to150", "压缩系数50-150kPa"
    CompressionFactor_0to100 = "compression_factor_0to100", "压缩系数0-100kPa"
    CompressionModulus = "compression_modulus", "压缩模量"
    SoilCharacteristicBearingCapacity = (
        "soil_characteristic_bearing_capacity",
        "地基承载力特征值f_{ak}",
    )
    SoilBearingCapacityFactorEtaB = (
        "soil_bearing_capacity_factor_eta_b",
        "承载力修正系数\\eta_b",
    )
    SoilBearingCapacityFactorEtaD = (
        "soil_bearing_capacity_factor_eta_d",
        "承载力修正系数\\eta_d",
    )
    ModifiedSoilCharacteristicBearingCapacity = (
        "modified_soil_characteristic_bearing_capacity",
        "修正后地基承载力特征值f_a",
    )
    DeepPlateLoadingTest = "deep_plate_loading_test", "深层平板载荷试验"
    GravityCollapseFactor = "gravity_collapse_factor", "自重湿陷系数"
    CollapseFactor = "collapse_factor", "湿陷系数"
    VoidRatio = "void_ratio", "孔隙比"
    NaturalWaterContent = "natural_water_content", "天然含水量"
    SPTNumber = "spt_number", "标贯击数"
    ModifiedSPTNumber = "modified_spt_number", "标贯修正击数"
    DPTNumber = "dpt_number", "动探击数"
    MeanLayerTopElevation = "mean_layer_top_elevation", "层底平均高程"
    MeanLayerBottomElevation = "mean_layer_bottom_elevation", "层底平均高程"
    LiquidityIndex = "liquidity_index", "液性指数"
    LiquidLimit = "liquid_limit", "液限"
    UCS = "ucs", "单轴抗压强度"
    SaturateUCS = "saturate_ucs", "饱和单轴抗压强度标准值f_{rk}"
    MinLayerTopDepth = "min_layer_top_depth", "最小层顶深度"
    MaxLayerTopDepth = "max_layer_top_depth", "最大层顶深度"
    MinLayerBottomDepth = "min_layer_bottom_depth", "最小层底深度"
    MaxLayerBottomDepth = "max_layer_bottom_depth", "最大层底深度"
    GeoAge = "geo_age", "地质时代"
    SoilType = "soil_type", "土体类别"
    ClayContent = "clay_content", "黏粒含量"
    SampleNumber = "sample_number", "取样编号"
    SampleDepth = "sample_depth", "样品深度"
    SampleTopDepth = "sample_top_depth", "样品顶深"
    SampleLength = "sample_length", "样品长度"
    LimitSkinFriction = "limit_skin_friction", "极限侧摩阻力标准值q_{ik}"
    LimitBaseResistance = "limit_base_resistance", "极限端阻力标准值q_{pk}"
    CharacteristicSkinFriction = (
        "characteristic_skin_friction",
        "侧摩阻力特征值q_{si}",
    )  # 侧摩阻力特征值 = 极限侧摩阻力标准值 / 2
    CharacteristicBaseResistance = (
        "characteristic_base_resistance",
        "端阻力特征值q_p",
    )  # 端阻力特征值 = 极限端阻力标准值 / 2
    GroutedSkinFrictionFactor = (
        "grouted_skin_friction_factor",
        "后注浆增强段桩侧阻力增大系数\\beta_{si}",
    )
    GroutedBaseResistanceFactor = (
        "grouted_base_resistance_factor",
        "后注浆增强段桩端阻力增大系数\\beta_p",
    )
    Cl = "cl", "氯离子Cl⁻"  # 对于水 mg/L，对于土 mg/kg
    SO42 = "so42", "硫酸盐SO_4^{2-}"  # 对于水 mg/L，对于土 mg/kg
    Mg2 = "mg2", "镁盐Mg^{2+}"  # 对于水 mg/L，对于土 mg/kg
    NH4 = "nh4", "铵盐NH_4^+"  # 对于水 mg/L，对于土 mg/kg
    OH = "oh", "苛性碱OH^-"  # 对于水 mg/L，对于土 mg/kg
    TotalMineralization = (
        "total_mineralization",
        "总矿化度",
    )  # 对于水 mg/L，对于土 mg/kg
    PH = "ph", "PH值"

    @classmethod
    def has_title(cls, title: str) -> bool:
        """Check if the given string is one of the titles in this enum"""
        return title in [prop.title for prop in cls]

    @classmethod
    def find_by_title(cls, title: str):
        """Find the enum member by its title, return None if not found"""
        for prop in cls:
            if prop.title == title:
                return prop
        return None


@unique
class SoilTypes(str, Enum):
    """Predefined soil type names"""

    def __new__(cls, value, title):
        obj = str.__new__(cls, value)
        obj._value_ = value
        obj._title = title  # type: ignore
        return obj

    @property
    def title(self):
        return self._title  # type: ignore

    Cohesive = "cohesive", "黏性土"
    Cohesionless = "cohesionless", "无黏性土"


@unique
class GeoResults(str, Enum):
    """Predefined geo calculation result names"""

    def __new__(cls, value, title):
        obj = str.__new__(cls, value)
        obj._value_ = value
        obj._title = title  # type: ignore
        return obj

    @property
    def title(self):
        return self._title  # type: ignore

    ProfileNumber = "profile_number", "剖面编号"
    BoreNumber = "bore_number", "钻孔编号"
    LayerTopElevation = "layer_top_elevation", "层顶标高"
    LayerBottomElevation = "layer_bottom_elevation", "层底标高"
    LayerDepth = "layer_depth", "层底深度"
    LayerThickness = "layer_thickness", "地层厚度"
    SF = "safety_factor", "安全系数"
    UndergroundWaterDepth = "underground_water_depth", "地下水位深度"
    FoundationDepth = "foundation_depth", "基础埋深"
    PileBearingCapacity = "pile_bearing_capacity", "桩竖向极限承载力标准值Q_{uk}"
    PileCharacteristicBearingCapacity = (
        "pile_characteristic_bearing_capacity",
        "桩竖向极限承载力特征值R_{a}",
    )
    PileLength = "pile_length", "桩长"
    PileBaseBlockingFactor = "pile_base_blocking_factor", "桩端阻塞效应系数\lambda_p"
    HollowPileNetArea = "hollow_pile_net_area", "空心桩桩端净面积A_j"
    HollowPileOpenArea = "hollow_pile_open_area", "空心桩敞口面积A_{pl}"
    RockPileDepthToDiameter = "rock_pile_depth_to_diameter", "嵌岩深径比h_r/d"
    RockPileResistanceFactor = (
        "rock_pile_resistance_factor",
        "嵌岩段侧阻和端阻综合系数\\zeta_r",
    )
    EffectivePeakAcceleration = "effective_peak_acceleration", "地震动峰值加速度"
    CharacteristicPeriodOfSeismicAccelerationResponseSpectrum = (
        "characteristic_period_of_seismic_acceleration_response_spectrum",
        "地震加速度反应谱特征周期",
    )
    SeismicDesignIntensity = "seismic_design_intensity", "抗震设防烈度"
    SeismicDesignGroup = "seismic_design_group", "设计地震分组"
    PileDiameter = "pile_diameter", "桩径"
    PileLayout = "pile_layout", "布桩方式"
    PileSpacing = "pile_spacing", "桩间距"
    LongitudinalSpacing = "longitudinal_spacing", "纵向桩间距"
    LateralSpacing = "lateral_spacing", "横向桩间距"
    AreaReplaceRatio = "area_replace_ratio", "面积置换率"
    CompositePileCharacteristicBearingCapacity = (
        "composite_pile_characteristic_bearing_capacity",
        "复合地基承载力特征值f_{spk}",
    )  # kPa
    CompositeSinglePileBearingCapacity = (
        "composite_single_pile_bearing_capacity",
        "单桩竖向承载力特征值R_{a}",
    )  # kN


@unique
class GeneralProps(str, Enum):
    """Predefined geo attribute names"""

    def __new__(cls, value, title):
        obj = str.__new__(cls, value)
        obj._value_ = value
        obj._title = title  # type: ignore
        return obj

    @property
    def title(self):
        return self._title  # type: ignore

    Longitude = "longitude", "经度"
    Latitude = "latitude", "纬度"
    XCoordinate = "x_coordinate", "X坐标"
    YCoordinate = "y_coordinate", "Y坐标"
    Elevation = "elevation", "高程"
    Name = "name", "名称"
    Building = "building", "建筑物"


@unique
class DataTypes(str, Enum):
    """Predefined data types"""

    def __new__(cls, value, title):
        obj = str.__new__(cls, value)
        obj._value_ = value
        obj._title = title  # type: ignore
        return obj

    @property
    def title(self):
        return self._title  # type: ignore

    Text = "text", "文本"
    FilePath = "file_path", "文件路径"
    FilesPath = "files_path", "文件路径列表"
    TemplatePath = "template_path", "模板文件路径"
    ImagePath = "image_path", "图片路径"
    ImagesPath = "images_path", "图片路径列表"


@unique
class BoreTypes(str, Enum):
    """Predefined bore type names"""

    def __new__(cls, value, title):
        obj = str.__new__(cls, value)
        obj._value_ = value
        obj._title = title  # type: ignore
        return obj

    @property
    def title(self):
        return self._title  # type: ignore

    @classmethod
    def values(cls):
        """Return a list of all enum values."""
        return [member.value for member in cls]

    @classmethod
    def titles(cls):
        """Return a list of all enum titles."""
        return [member.title for member in cls]

    IdentificationBore = "identification_bore", "鉴别孔"
    SoilSamplingBore = "soil_sampling_bore", "取土试样钻孔"
    WaterSamplingBore = "water_sampling_bore", "取水试样钻孔"
    SoilWaterSamplingBore = "soil_water_sampling_bore", "取土、取水试样钻孔"
    SPTBore = "spt_bore", "标准贯入试验孔"
    SoilSamplingSPTBore = "soil_sampling_spt_bore", "取土标贯钻孔"
    CPTBore = "cpt_bore", "静力触探试验孔"
    DPTBore = "dpt_bore", "圆锥动力触探试验孔"
    SoilWaterSPTBore = "soil_water_spt_bore", "取土、取水标贯钻孔"
    VaneShearTestBore = "vane_shear_test_bore", "十字板剪切试验孔"
    WaveVelocityTestBore = "wave_velocity_test_bore", "波速试验孔"
    PumpingTestBore = "pumping_test_bore", "抽水试验孔"
    WaterInjectionTestBore = "water_injection_test_bore", "注水试验孔"
    PressureWaterTestBore = "pressure_water_test_bore", "压水试验孔"
    PressuremeterTestBore = "pressuremeter_test_bore", "旁压试验孔"
    SoilSamplingWell = "soil_sampling_well", "取土井孔"
    WaterSamplingWell = "water_sampling_well", "取水井孔"
    SoilWaterSamplingWell = "soil_water_sampling_well", "取土、取水井孔"
    ExplorationTrench = "exploration_trench", "探槽"
    SoilSamplingTestPit = "soil_sampling_test_pit", "取土试样探井"
    WaterSamplingTestPit = "water_sampling_test_pit", "取水试样探井"
    SoilWaterSamplingTestPit = "soil_water_sampling_test_pit", "取土、取水试样探井"
    SimplePermeabilityTestWell = "simple_permeability_test_well", "简易渗水试验井"
    SimplePumpingTestWell = "simple_pumping_test_well", "简易抽水试验井"
    LargeDirectShearTestPoint = "large_direct_shear_test_point", "大型直剪试验点"
    PlateLoadTestPoint = "plate_load_test_point", "平板载荷试验点"
    LongTermMonitoringBore = "long_term_monitoring_bore", "长期观测孔"
    GeophysicalSurveyPoint = "geophysical_survey_point", "物探点"
    GeophysicalAnomalyPoint = "geophysical_anomaly_point", "物探异常点"
    SmallAugerDrill = "small_auger_drill", "小螺旋钻"
    RockSamplingBore = "rock_sampling_bore", "取岩石试样的钻孔"
    ScrewPlateLoadTestPoint = "screw_plate_load_test_point", "螺旋板载荷试验点"


if __name__ == "__main__":
    print(GeneralProps.XCoordinate.title)
    print(GeoMaterialProps.MaterialID.title)
    print(GeoResults.RockPileResistanceFactor.title)
